#include "StdAfx.h"
#include <string>
#include "ViewMedia.h"
#include "PlayMediaGraph.h"


CPlayMediaGraph * pview = NULL;
CViewMedia::CViewMedia(void)
{
}


CViewMedia::~CViewMedia(void)
{
}

// SetViewFile
//void CViewMedia::SetViewFile(const std::wstring & filename)
//{
//	m_filename = filename ;
//}


// StartView
void CViewMedia::StartView(const std::wstring & filename,const HWND hwnd,
		const double  startpoint)
{
	if(pview != NULL)
	{
		delete pview;
		pview = NULL;
	}
	pview = new CPlayMediaGraph();
	bool bresult = pview->Create();
	if (pview)
	{
		bresult =pview->QueryInterfaces();
		if(bresult)
		{
			pview->RenderFile(filename);
			pview->CreateCaptureShow(hwnd);
			pview->SetCurrentPosition(startpoint);
			pview->Run();
		}
	}
}


// StopView
void CViewMedia::StopView(void)
{
	if(pview)
	{
		pview->Stop();
	}
}


// PauseView
void CViewMedia::PauseView(void)
{
	if(pview)
	{
		pview->Pause();
	}
}


void CViewMedia::ResetView(HWND hwnd)
{
	if(pview == NULL)
	{
		return;
	}
	if(hwnd == NULL)
	{
		return;
	}
	pview->CreateCaptureShow( hwnd);
}